package org.syncsoft.overalt.domain.community.entity;

import java.util.Collection;

import org.apache.commons.lang.StringEscapeUtils;
import org.syncsoft.overalt.domain.common.entity.IEntity;
import org.syncsoft.overalt.domain.user.entity.User;

/**
 * Class of domain that represents the a.m.i.g.o.s. community
 * @author hfa
 *
 */
public class Community implements IEntity {

	private int code;
	private User owner;
	private String name;
	private String description;
	private Collection<User> members;
	
	public Community() {
	}
	
	public Community(int code) {
		setCode(code);
	}
	
	@Override
	public int hashCode() {
		return getCode();
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof Community && ((Community)obj).getCode() == getCode()) {
			return true;
		}
		return false;
	}
	
	@Override
	public String toString() {
		return getName();
	}

	//	GETs AND SETs
	public int getCode() {
		return code;
	}
	public void setCode(int code) {
		this.code = code;
	}
	public User getOwner() {
		return owner;
	}
	public void setOwner(User owner) {
		this.owner = owner;
	}
	public Collection<User> getMembers() {
		return members;
	}
	public void setMembers(Collection<User> members) {
		this.members = members;
	}
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = StringEscapeUtils.unescapeHtml(description);
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = StringEscapeUtils.unescapeHtml(name);
	}
}
